package book.dao.Impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import book.dao.ShowDao;
import book.dao.SqlSessionFactoryUtil;
import book.entity.Book;

public class ShowDaoImpl implements ShowDao {

	public List<Book> showAllBooks(int pageFirst,int currentPage) {
		SqlSession se=null;
		List<Book> list=null;
		try {
			se=SqlSessionFactoryUtil.getSqlSession();
			ShowDao dao=se.getMapper(ShowDao.class);
			list=dao.showAllBooks(pageFirst, currentPage);
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			se.close();
		}
		return list;
	}
	
	public int countAllBooks(){
		int count=0;
		SqlSession se=null;
		try{
			se=SqlSessionFactoryUtil.getSqlSession();
			ShowDao dao=se.getMapper(ShowDao.class);
			count=dao.countAllBooks();
		}catch (Exception e) {
			e.printStackTrace();
		}finally {
			se.close();
		}
		return count;
	}

}
